package top.datacluster.basic.offer;

public class OddEvenSort {

    public static void main(String[] args) {
        int[] a = new int[]{2, 3, 1, 5, 4, 6, 7, 8};
        sort(a);
        for (int i : a){
            System.out.print(i + " ");
        }
    }

    public static void sort(int[] array){
        int right = array.length - 1;
        int left = 0;
        while (left < right){
            if (array[right] % 2 == 0){
                right--;
                continue;
            }else{
                if (array[left] % 2 != 0){
                    left++;
                    continue;
                }else{
                    int temp = array[right];
                    array[right] = array[left];
                    array[left] = temp;
                }
            }

        }
    }
}
